home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / assemblr / library / asm_kit / gun.asm < prev    next >
Assembly Source File  |  1985-06-21  |  3KB  |  66 lines

  1. ;GUN--Make machine gun sound
  2. ;  fires fixed number of shotsset
  3. ;
  4. ;********************************************************************
  5. prognam       segment                  ;define code segment
  6. ;
  7. ;-------------------------------------------------------------------
  8. main          proc      far            ;main part of program
  9. ;
  10.               assume    cs:prognam
  11. ;
  12. ;REM--        org       100h           ;start of program
  13. ;
  14. start:                                 ;starting execution address
  15. ;
  16.               mov  cx,20d              ;set number of shots
  17. new_shot:
  18.               push cx                  ;save count
  19.               call shoot               ;sound of shot
  20.               mov  cx,4000h            ;set up silent delay
  21. silent:       loop silent              ;silent delay
  22.               pop  cx                  ;get shot count back
  23.               loop new_shot            ;loop till shots done
  24.               int  20h                 ;return to DOS
  25. ;
  26. main          endp                     ;end of main part of program
  27. ;--------------------------------------------------------------------
  28. ;SUBROUTINE TO MAKE BRIEF NOISE
  29. ;
  30. shoot         proc  near
  31. ;
  32.               mov  dx,140h             ;initial value of wait
  33.               mov  bx,20h              ;set count
  34. ;
  35.               in   al,61h              ;get port 61
  36.               and  al,11111100b        ;and off bits 0, 1
  37. sound:        xor  al,2                ;toggle bit #1 in AL
  38.               out  61h,al              ;output to port 61
  39. ;
  40.               add  dx,9248h            ;add random pattern
  41.               mov  cl,3                ;set to rotate 3 bits
  42.               ror  dx,cl               ;rotate it
  43. ;
  44.               mov  cx,dx               ;put in CX
  45.               and  cx,1ffh             ;mask off upper 7 bits
  46.               or   cx,10h              ;ensure not to long
  47. ;
  48. wait:         loop wait                ;wait
  49. ;
  50. ;
  51. ;made noise long enough?
  52.               dec  bx                  ;done enough?
  53.               jnz  sound               ;jump if not yet
  54. ;
  55. ;turn off sound
  56.               and  al,11111100b        ;AND off bits 0, 1
  57.               out  61,al               ;turn off bits 0,1
  58. ;
  59.               ret                      ;return from subroutine
  60. ;
  61. shoot        endp
  62. ;--------------------------------------------------------------------
  63. prognam       ends                     ;end of code segment
  64. ;********************************************************************
  65.               end                      ;end assembly
  66.